<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="file_name" placeholder="请输入图片名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-file-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
                <div class="layui-inline" style="float: right;margin-right: 10px">
                    <button type="button" class="layui-btn layui-btn-normal" id="LAY-upload-image">上传图片</button>
                    <div class="layui-progress" lay-filter="progress" lay-showPercent="yes">
                        <div class="layui-progress-bar layui-bg-green" lay-percent="0%"></div>
                    </div>
                </div>
                <div class="layui-inline" style="float: right;">
                    <div id="LAY-upload-image-preview">
                        <span id="LAY-upload-image-normal"></span>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table id="LAY-app-attachment-image" lay-filter="LAY-app-attachment-image"></table>
            <script type="text/html" id="imageTpl">
                <img style="display: inline-block; height: 32px;" src="{{ d.file_path }}">
            </script>
            <script type="text/html" id="table-file-list">
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="select"><i
                        class="layui-icon layui-icon-circle"></i></a>
            </script>
        </div>
    </div>
</div>

<script>
    layui.use('attachment', layui.factory('attachment')).use(['index', 'storage', 'table'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , table = layui.table
            , form = layui.form;

        //监听搜索
        form.on('submit(LAY-app-file-search)', function (data) {
            var field = data.field;

            //执行重载
            table.reload('LAY-app-attachment-image', {
                where: field
            });
        });
    });
</script>
